package com.misssad.service;

import javax.annotation.Resource;

import org.bson.Document;
import org.springframework.stereotype.Service;

import com.misssad.enums.ResultEnum;
import com.misssad.exception.GirlException;
import com.misssad.repository.GirlRepository;

@Service
public class GrilService {
	
	@Resource
	private GirlRepository girlRepository;
	

	/**
	 * 
	 * @param id
	 * @throws Exception 
	 */
	public void getAge(String id) throws Exception {

		Document document = girlRepository.findOne(id);
		Integer age = document.getInteger("age");
		if(age < 10){
			//返回“你还在上小学吧”
			throw new GirlException(ResultEnum.PRIMARY_SCHOOL);
		}else if(age > 10 && age <16){
			//返回“你可能在上初中”
			throw new GirlException(ResultEnum.MIDDLE_SCHOOL);
		}
		
		
	}

}
